package com.syscom.qcRule;

import com.syscom.qcRule.util.QCRuleCal;
import com.syscom.sar.server.rsk.vo.OdrInfo;
import com.syscom.sar.server.rsk.vo.SarCODT;
import com.syscom.sar.server.rsk.vo.SarNBST;
import com.syscom.server.cache.safeCache.vo.AccuRuleBrokerCacheVo;
import com.syscom.server.qc.cacheManager.AccuRule4CacheManager;

/**
 * Rule2701
 * [商品][信用搶配]單日融資買進委託數量限制(張)
 * 
 * @author Jean
 */
public class QCRule2701 implements QCRuleCal {
	
	@Override
	public double[] calGeneral(int iRuleId, double[] dValues, OdrInfo odrInfo) {
		AccuRuleBrokerCacheVo newVo = getNewAccuRuleValue(iRuleId, odrInfo.getProdId());
		double dValue = (dValues != null && dValues.length != 0) ? dValues[0] : 0;
		double dRuleValue = AccuRule4CacheManager.getInstance().updateRuleValue(iRuleId, odrInfo.getProdId(), newVo, dValue);
		return new double[] {dRuleValue} ;
	}
	
	@Override
	public void calGeneralRollback(int iRuleId, double[] dValues, OdrInfo odrInfo) {
		AccuRule4CacheManager.getInstance().rollbackRuleValue(iRuleId, odrInfo.getProdId(), dValues[0]);
	}
	
	@Override
	public double[] calCODT(int iRuleId, SarCODT codtVo, double[] dValues) {
		return null;
	}

	@Override
	public double[] calNBST(int iRuleId, SarNBST nbstVo, double[] dValues) {
		return null;
	}

	private AccuRuleBrokerCacheVo getNewAccuRuleValue(int iRuleId, String sProdId) {
		AccuRuleBrokerCacheVo newAccuRuleValue = new AccuRuleBrokerCacheVo(sProdId, iRuleId, 0);
		return newAccuRuleValue;
	}

}
